﻿#pragma once
#ifndef RGSATTRIBUTETABLE_H
#define RGSATTRIBUTETABLE_H

#include<QtMath>
#include <QWidget>
#include <QTableView>
#include<QToolBar>
#include<QPushButton>
#include<QHBoxLayout>

#include<qgsvectorlayer.h>
#include <qgsattributetablemodel.h>
#include<QgsAttributeTableFilterModel.h>
#include<qgsvectorlayercache.h>
#include<qgsfeaturelistmodel.h>
#include<qgsattributetabledelegate.h>
#include<qgsattributetableview.h>
#include<qgsvectorlayerutils.h>
#include "ui_rgsattributetable.h"

namespace Ui {
class qgsattributetablebase;

}

class rgsattributetable : public QWidget
{
    Q_OBJECT
public:
    explicit rgsattributetable(QgsVectorLayer* layer,QgsMapCanvas *mapCanvas,
                               QgsAttributeTableFilterModel::FilterMode initialMode,
                               Qt::WindowFlags flags,QWidget *parent,const QString &filterExpression);
    void initLayerCache( bool cacheGeometry );
    void initModels( QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request, bool loadFeatures );
    void inittiilbar();
    void initlineEditwidget();
    void actionStatus();

signals:
    void emitmessage(const QString &title, const QString &message);
public slots:
    void comfirmSelectExpression();

protected:
    //QTableView* mMainview;
    QgsAttributeTableView* mMainview;
    QgsAttributeTableModel* mMasterModel;
    QgsAttributeTableFilterModel* mFilterModel;
    QgsVectorLayerCache* mLayerCache;
    QgsVectorLayer* mLayer;
    //QgsFeatureListModel* mFeatureListModel;
    Ui::qgsattributetablebase* UiWidget;
    QToolBar* toolbar;
    QLineEdit* lineEdit;
    QPushButton* btnconfirm;
    QgsMessageBar* m_info;
    QFrame* selectExpressionFrame;

    //
    int viewRow;
    int viewCol;
    bool editLineOn=false;
    QLineEdit* editLine;
public:
    //virtual void mouseDoubleClickEvent(QMouseEvent *event);
private slots:
    void on_actionSelect_All_triggered();
    void on_actionnvertSelection_triggered();
    void on_actionremoveSelection_triggered();
    void on_actionsetSelectedOnTop_toggled(bool checked);
    void on_actionZoomMapToSelectedRows_triggered();
    void on_actionpanToSelected_triggered();
    void on_actionselectExpression_triggered();
    void on_actiontest_triggered();
    void on_actionactionToggleEditing_toggled(bool arg1);
};

#endif // RGSATTRIBUTETABLE_H
